<template>
  <div>
    <!-- 面包屑导航 -->
    <div class="page_top">
      <div class="left_btn" @click="back">
        <img src="../../assets/image/back.png" alt="" />
      </div>
      <crumbs basetitle="客户" title="客户管理" title1="客户详情"></crumbs>
    </div>
    <div class="content">
      <div class="company">
        <el-card>
          <div class="companystatus">
            <span>{{ form1.companyname }}</span>
            <!-- <el-select v-model="cauditStatus" class="m-2" :placeholder="auditStatus" size="small">
              <el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
            </el-select> -->
            <div class="companystatuslist" @click="chgangecompanystatus">
              <div>
                <span v-show="cauditStatus == '0'">待审核</span>
                <span v-show="cauditStatus == '1'">审核通过</span>
                <span v-show="cauditStatus == '2'">审核驳回</span>
              </div>
              <el-icon>
                <ArrowDown />
              </el-icon>
            </div>
          </div>
          <div class="companyse_time">
            <div class="l">
              <img src="../../assets/image/容器(1).png" alt="" />
              <span>开通时间：{{ starttime }}</span>
            </div>
            <div class="r">
              <img src="../../assets/image/容器(2).png" alt="" />
              <span>到期时间：{{ endtime }}</span>
            </div>
            <div class="note">
              <img src="../../assets/image/容器(3).png" alt="" />
              <span>群发短信剩余条数：{{ smsBalance }}</span>
            </div>
          </div>
        </el-card>
      </div>
      <div class="companymsg">
        <div class="l">
          <div class="basemsg">
            <el-card>
              <div class="title">基础信息</div>
              <el-form style="margin-top: 25px; padding: 20px; box-sizing: border-box" :model="form1" label-width="120px">
                <div style="display: flex">
                  <el-form-item label="公司简称" style="flex: 1">
                    <el-input placeholder="请输入公司简称" v-model="form1.companyAbbreviation" disabled />
                  </el-form-item>
                  <el-form-item label="收款账户" style="flex: 1">
                    <el-select v-model="form1.receiptId" class="m-2" :placeholder="form1.bankName" style="width: 100%;">
                      <el-option v-for="item in adminrechargetype" :key="item.receiptId" :label="item.bankName"
                        :value="item.receiptId" />
                    </el-select>
                  </el-form-item>
                </div>
                <el-form-item label="营业执照编码">
                  <el-input placeholder="请输入营业执照编码" v-model="form1.coding" />
                </el-form-item>
                <div style="display: flex">
                  <el-form-item label="法人姓名" style="flex: 40%">
                    <el-input placeholder="请输入法人姓名" v-model="form1.legalpersonname" />
                  </el-form-item>
                  <el-form-item label="开户行及行号" style="flex: 60%">
                    <el-input placeholder="请输入开户行及行号" v-model="form1.openingbank" />
                  </el-form-item>
                </div>
                <el-form-item label="地址">
                  <el-input placeholder="请输入地址" v-model="form1.address" />
                </el-form-item>
              </el-form>
              <div class="" style="
                  display: flex;
                  align-items: center;
                  justify-content: center;
                ">
                <el-button class="my_cancelbtn" @click="basemsgcancel">取消</el-button>
                <el-button type="primary" class="my_btn" @click="basemsgonSubmit('basemsg')">确定</el-button>
              </div>
            </el-card>
          </div>
          <div class="team">
            <el-card>
              <div class="title">团队成员</div>
              <el-table :data="teamtableData" style="width: 100%; margin-top: 16px" :header-cell-style="{
                background: '#FAFAFC',
                color: '#202536',
              }">
                <el-table-column align="center" prop="userName" label="姓名" />
                <el-table-column align="center" prop="phone" label="手机号" />
                <el-table-column align="center" prop="position" label="职位" />
                <el-table-column align="center" prop="roleName" label="角色">
                </el-table-column>
                <el-table-column align="center" prop="isOpen" label="PC">
                  <template #default="scope">
                    <span v-if="scope.row.isOpen === 1">已开通</span>
                    <span v-else>未开通</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="操作" width="260">
                  <template #default="scope">
                    <div style="
                        display: flex;
                        align-items: center;
                        justify-content: space-around;
                      ">
                      <el-button link style="color: #0256ff" @click="setorcanceladmin(scope.row)">设置超级管理员</el-button>
                      <el-button link style="color: #0256ff" @click="changeroleapizzc(scope.row)">修改角色</el-button>
                      <el-dropdown>
                        <span style="color: #0256ff" class="el-dropdown-link">
                          更多
                        </span>
                        <template #dropdown>
                          <el-dropdown-menu>
                            <el-dropdown-item style="color: #0256ff" v-if="scope.row.isOpen === 0"
                              @click="openpczzc(scope.row)">开通PC</el-dropdown-item>
                            <el-dropdown-item style="color: #0256ff" @click="okornologin(scope.row)">{{
                              scope.row.status === "0"
                              ? "禁止登录"
                              : "允许登录"
                            }}</el-dropdown-item>
                            <el-dropdown-item style="color: #0256ff"
                              @click="openresetpasswordzzc(scope.row)">重置密码</el-dropdown-item>
                            <el-dropdown-item v-if="scope.row.isAdmin === 1" style="color: #ee3737"
                              @click="setadmins(scope.row)">
                              取消管理员
                            </el-dropdown-item>
                            <el-dropdown-item v-if="scope.row.isAdmin === 0" style="color: #0256ff"
                              @click="setadmins(scope.row)">
                              设置管理员
                            </el-dropdown-item>
                          </el-dropdown-menu>
                        </template>
                      </el-dropdown>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
              <pagination :total="teamtotal" :currentPage="teamcurrentPage" :pageSize="teampageSize"
                @SizeChange="teamhandleSizeChange" @CurrentChange="teamhandleCurrentChange"></pagination>
            </el-card>
          </div>
          <div class="recharge">
            <el-card>
              <div class="title">充值记录</div>
              <el-radio-group style="margin-top: 16px" v-model="radio" @change="rechargetypechange">
                <el-radio label="">全部</el-radio>
                <el-radio label="0">子弹发薪</el-radio>
                <el-radio label="2">日日保</el-radio>
                <el-radio label="3">长期保</el-radio>
                <el-radio label="1">电子签</el-radio>
                <el-radio label="4">群发消息</el-radio>
              </el-radio-group>
              <el-table :data="rechargetableData" style="width: 100%; margin-top: 16px" :header-cell-style="{
                background: '#FAFAFC',
                color: '#202536',
              }">
                <el-table-column align="center" prop="productType" label="产品">
                  <template #default="scope">
                    <span v-if="scope.row.productType === 0">子弹发薪</span>
                    <span v-else-if="scope.row.productType === 1">电子签</span>
                    <span v-else-if="scope.row.productType === 2">日日保</span>
                    <span v-else-if="scope.row.productType === 3">长期保</span>
                    <span v-else-if="scope.row.productType === 4">群发消息</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="payMoney" label="充值金额" />
                <el-table-column align="center" prop="createTime" label="充值时间" />
                <el-table-column align="center" prop="remark" label="备注">
                  <template #default="scope">
                    <div style="
                        display: flex;
                        align-items: center;
                        justify-content: center;
                      ">
                      <el-tooltip class="box-item" effect="dark" :content="scope.row.remark" placement="bottom">
                        <div style="
                            margin-right: 5px;
                            width: 80px;
                            white-space: nowrap;
                            overflow: hidden;
                            text-overflow: ellipsis;
                          ">
                          {{ scope.row.remark }}
                        </div>
                      </el-tooltip>
                      <el-tag v-show="scope.row.status === 1">已审核</el-tag>
                      <el-tag v-show="scope.row.status === 2" class="ml-2" type="danger">已驳回</el-tag>
                      <el-tag v-show="scope.row.status === 0" class="ml-2" type="info">待审核</el-tag>
                      <el-tag v-show="scope.row.status === 3" class="ml-2" type="">已提现</el-tag>
                      <el-tag v-show="scope.row.status === 4" class="ml-2" type="success">已转出</el-tag>
                      <el-tag v-show="scope.row.status === 5" class="ml-2" type="warning">已转入</el-tag>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="充值凭证" width="120">
                  <template #default="scope">
                    <span v-if="scope.row.voucherUrl != ''" style="color: #3e5ff5; cursor: pointer"
                      @click="checkvoucher(scope.row.voucherUrl)">查看凭证</span>
                    <span v-else>查看凭证</span>
                  </template>
                </el-table-column>
              </el-table>
              <pagination :total="rechargetotal" :currentPage="rechargecurrentPage" :pageSize="rechargepageSize"
                @SizeChange="rechargehandleSizeChange" @CurrentChange="rechargehandleCurrentChange"></pagination>
            </el-card>
          </div>
        </div>
        <div class="r">
          <div class="goodsmsg">
            <el-card>
              <div class="title">产品信息</div>
              <div class="demo-collapse">
                <el-collapse>
                  <el-collapse-item name="1">
                    <template #title>
                      <div @click="openorclose(1)" style="
                          display: flex;
                          align-items: center;
                          background-color: #ebeffe;
                          width: 100%;
                          height: 40px;
                          border-radius: 8px;
                        ">
                        <div :class="{
                          fold: true,
                          foldflagup: foldflagone === false,
                          foldflagdown: foldflagone,
                        }">
                          <img src="../../assets/image/组1038.png" alt="" />
                        </div>
                        <div class="collapse_title">
                          <span>子弹发薪<span style="
                                margin-left: 8px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #ffffff;
                                color: #0256ff;
                              " v-if="bulletform.isOpenPaySalary === 1">已开通</span><span style="
                                margin-left: 8px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #eaeaef;
                                color: #9497b1;
                              " v-if="bulletform.isOpenPaySalary === 0">未开通</span></span><span class="rechargebtn"
                            @click.stop="bulletpayrechargeapipay">充值</span>
                        </div>
                      </div>
                    </template>
                    <div>
                      <span>发薪总额：</span><span>￥{{ bulletform.patMoneyCount }}</span>
                    </div>
                    <div style="margin-top: 16px">
                      <el-form :model="bulletform" label-width="120px">
                        <el-form-item label="所属销售：">
                          <el-select v-model="bulletform.paySaleid" :placeholder="cpaySaleName"
                            @change="changebullmarket">
                            <el-option v-for="item in allseller" :key="item.saleId" :label="item.saleName"
                              :value="item.id" />
                          </el-select>
                        </el-form-item>
                        <el-form-item label="剩余月数：">
                          <el-input v-model="bulletform.validTime" disabled />
                        </el-form-item>
                        <el-form-item label="账户剩余金额：">
                          <el-input v-model="bulletform.payAccountBalance" disabled />
                        </el-form-item>
                        <!-- <el-form-item label="剩余金额：">
                          <el-input v-model="bulletform.payAccountBalance" />
                        </el-form-item> -->
                        <el-form-item label="商户号：">
                          <el-input v-model="bulletform.subMchid" />
                        </el-form-item>
                        <el-form-item label="充值账号：">
                          <el-input v-model="bulletform.merchantBankCard" />
                        </el-form-item>
                        <el-form-item label="收款账号：">
                          <el-select v-model="bulletform.receiptId" class="m-2">
                            <el-option v-for="item in adminrechargetype" :key="item.receiptId" :label="item.bankName"
                              :value="item.receiptId" />
                          </el-select>
                        </el-form-item>
                        <el-form-item label="单日额度：">
                          <el-input v-model="bulletform.dailyQuota" />
                        </el-form-item>
                        <el-form-item label="单日可领额度：">
                          <el-input v-model="bulletform.personSingleQuota" />
                        </el-form-item>
                        <div style="
                            display: flex;
                            align-items: center;
                            justify-content: center;
                          ">
                          <el-button class="my_btn" type="primary" v-if="bulletform.isOpenPaySalary === 0"
                            @click="bullmsgonSubmit('bullmsg', 1)">确定开通</el-button>
                          <el-button class="my_btn" type="primary" v-if="bulletform.isOpenPaySalary === 1" @click="
                            bullmsgonSubmit(
                              'bullmsg',
                              bulletform.isOpenPaySalary
                            )
                            ">确定修改</el-button>
                        </div>
                      </el-form>
                    </div>
                  </el-collapse-item>
                  <el-collapse-item name="2">
                    <template #title>
                      <div @click="openorclose(2)" style="
                          display: flex;
                          align-items: center;
                          background-color: #fafafc;
                          width: 100%;
                          height: 40px;
                          border-radius: 8px;
                        ">
                        <div :class="{
                          fold: true,
                          foldflagup: foldflagtwo === false,
                          foldflagdown: foldflagtwo,
                        }">
                          <img src="../../assets/image/组1038.png" alt="" />
                        </div>
                        <div class="collapse_title">
                          <span>日日保<span style="
                                margin-left: 21px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #e0eaff;
                                color: #0256ff;
                              " v-if="everyform.isOpenWesure === 1">已开通</span><span style="
                                margin-left: 21px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #eaeaef;
                                color: #9497b1;
                              " v-if="everyform.isOpenWesure === 0">未开通</span></span><span class="rechargebtn"
                            @click.stop="everypay">充值</span>
                        </div>
                      </div>
                    </template>
                    <div>
                      <span>理赔率：</span><span>{{ everyform.insureClaimRate }}</span><span
                        style="margin-left: 20px">当前费率：</span><span>+{{ everyform.insureIncreaseRate * 100 }}%</span>
                    </div>
                    <div style="margin-top: 16px">
                      <el-form :model="form" label-width="120px">
                        <el-form-item label="所属销售：">
                          <el-select v-model="everyform.saleId" :placeholder="everyform.plach"
                            @change="changeeverymarket">
                            <el-option v-for="item in allseller" :key="item.saleId" :label="item.saleName"
                              :value="item.id" />
                          </el-select>
                        </el-form-item>
                        <el-form-item label="保费余额：">
                          <el-input v-model="everyform.ye" placeholder="请输入保费余额" disabled />
                        </el-form-item>
                        <el-form-item label="保险公司：">
                          <el-select v-model="everyform.bxcompany" :multiple="false" filterable allow-create
                            default-first-option :reserve-keyword="false" placeholder="请选择保险公司"
                            @change="changeeverybxcompany">
                            <el-option v-for="item in dailybxcompany" :key="item.dictValue" :label="item.dictLabel"
                              :value="item.dictValue" />
                          </el-select>
                        </el-form-item>
                        <el-form-item label="投保方案：">
                          <el-select v-model="everyform.bxtype" multiple filterable allow-create default-first-option
                            :reserve-keyword="false" placeholder="请选择投保方案">
                            <el-option v-for="item in everybxtype" :key="item.dictValue" :label="item.dictLabel"
                              :value="item.dictValue" />
                          </el-select>
                        </el-form-item>
                        <div style="
                            display: flex;
                            align-items: center;
                            justify-content: center;
                          ">
                          <el-button type="primary" class="my_btn" v-if="everyform.isOpenWesure === 0"
                            @click="everymsgonSubmit('everymsg', 1)">确定开通</el-button>
                          <el-button class="my_btn" type="primary" v-if="everyform.isOpenWesure === 1" @click="
                            everymsgonSubmit(
                              'everymsg',
                              everyform.isOpenWesure
                            )
                            ">确定修改</el-button>
                        </div>
                      </el-form>
                    </div>
                  </el-collapse-item>
                  <el-collapse-item name="3">
                    <template #title>
                      <div @click="openorclose(3)" style="
                          display: flex;
                          align-items: center;
                          background-color: #fafafc;
                          width: 100%;
                          height: 40px;
                          border-radius: 8px;
                        ">
                        <div :class="{
                          fold: true,
                          foldflagup: foldflagthree === false,
                          foldflagdown: foldflagthree,
                        }">
                          <img src="../../assets/image/组1038.png" alt="" />
                        </div>
                        <div class="collapse_title">
                          <span>长期保<span style="
                                margin-left: 21px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #e0eaff;
                                color: #0256ff;
                              " v-if="longform.isOpenPeriod === 1">已开通</span><span style="
                                margin-left: 21px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #eaeaef;
                                color: #9497b1;
                              " v-if="longform.isOpenPeriod === 0 ||
                                longform.isOpenPeriod === null
                                ">未开通</span></span><span class="rechargebtn" @click.stop="longpay">充值</span>
                        </div>
                      </div>
                    </template>
                    <div>
                      <span>理赔率：</span><span>{{ longform.insureClaimRate }}</span>
                      <!-- <span style="margin-left: 20px">当前费率：</span
                      ><span>0%</span> -->
                    </div>
                    <div style="margin-top: 16px">
                      <el-form :model="longform" label-width="120px">
                        <el-form-item label="所属销售：">
                          <el-select v-model="longform.longxs" :placeholder="clongxs" @change="changelongmarket">
                            <el-option v-for="item in allseller" :key="item.saleId" :label="item.saleName"
                              :value="item.id" />
                          </el-select>
                        </el-form-item>
                        <el-form-item label="保费余额：">
                          <el-input v-model="longform.wesureBalance" disabled />
                        </el-form-item>
                        <el-form-item label="保险公司：">
                          <el-select v-model="longform.bxcompany" multiple filterable allow-create default-first-option
                            :reserve-keyword="false" placeholder="请选择保险公司" @change="changelongtimecompany">
                            <el-option v-for="item in longbxcompany" :key="item.dictValue" :label="item.dictLabel"
                              :value="item.dictValue" />
                          </el-select>
                        </el-form-item>
                        <el-form-item label="投保人数：">
                          <el-input v-model="longform.periodInsureCount" disabled />
                        </el-form-item>
                        <el-form-item label="投保方案：">
                          <el-select v-model="longform.bxtype" multiple filterable allow-create default-first-option
                            :reserve-keyword="false" placeholder="请选择投保方案">
                            <el-option v-for="item in longbxtype" :key="item.dictValue" :label="item.dictLabel"
                              :value="item.dictValue" />
                          </el-select>
                        </el-form-item>
                        <div style="
                            display: flex;
                            align-items: center;
                            justify-content: center;
                          ">
                          <el-button type="primary" class="my_btn" v-if="longform.isOpenPeriod === 0"
                            @click="longmsgonSubmit('longmsg', 1)">确定开通</el-button>
                          <el-button type="primary" class="my_btn" v-if="longform.isOpenPeriod === 1" @click="
                            longmsgonSubmit('longmsg', longform.isOpenPeriod)
                            ">确定修改</el-button>
                        </div>
                      </el-form>
                    </div>
                  </el-collapse-item>
                  <el-collapse-item name="4">
                    <template #title>
                      <div @click="openorclose(4)" style="
                          display: flex;
                          align-items: center;
                          background-color: #f9fbff;
                          width: 100%;
                          height: 40px;
                          border-radius: 8px;
                        ">
                        <div :class="{
                          fold: true,
                          foldflagup: foldflagfour === false,
                          foldflagdown: foldflagfour,
                        }">
                          <img src="../../assets/image/组1038.png" alt="" />
                        </div>
                        <div class="collapse_title">
                          <span>电子签<span style="
                                margin-left: 21px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #e0eaff;
                                color: #0256ff;
                              " v-if="eleform.isOpenEleSign === 1">已开通</span><span style="
                                margin-left: 21px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #eaeaef;
                                color: #9497b1;
                              " v-if="eleform.isOpenEleSign === 0">未开通</span></span><span class="rechargebtn"
                            @click.stop="elepay">充值</span>
                        </div>
                      </div>
                    </template>
                    <div style="margin-top: 16px">
                      <el-form :model="eleform" label-width="120px">
                        <el-form-item label="剩余份数：">
                          <el-input v-model="eleform.eleAmount" disabled />
                        </el-form-item>
                        <el-form-item label="已签署：">
                          <el-input v-model="eleform.eleSignConsumeAmount" disabled />
                        </el-form-item>
                        <el-form-item label="签署失败：">
                          <el-input v-model="eleform.signingFailedRecordAmount" disabled />
                        </el-form-item>
                        <el-form-item label="开通日期：">
                          <el-date-picker disabled v-model="eleform.eleProductOpenTime" type="date" placeholder="请选择开通时间"
                            @change="changeeledate" />
                        </el-form-item>
                        <el-form-item label="签署记录：">
                          <div style="color: rgba(35, 97, 255, 1); cursor: pointer">
                            <el-icon>
                              <Link />
                            </el-icon><span>点击查看</span>
                          </div>
                        </el-form-item>
                        <div style="
                            display: flex;
                            align-items: center;
                            justify-content: center;
                          "></div>
                      </el-form>
                    </div>
                  </el-collapse-item>
                  <el-collapse-item name="5">
                    <template #title>
                      <div @click="openorclose(5)" style="
                          display: flex;
                          align-items: center;
                          background-color: #fafafc;
                          width: 100%;
                          height: 40px;
                          border-radius: 8px;
                        ">
                        <div :class="{
                          fold: true,
                          foldflagup: foldflagfive === false,
                          foldflagdown: foldflagfive,
                        }">
                          <img src="../../assets/image/组1038.png" alt="" />
                        </div>
                        <div class="collapse_title">
                          <span>群发消息<span style="
                                margin-left: 10px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #e0eaff;
                                color: #0256ff;
                              " v-if="messageform.openStauts === 1">已开通</span><span style="
                                margin-left: 10px;
                                font-size: 8px;
                                border-radius: 1.5px;
                                padding: 2.5px 3.5px;
                                background-color: #eaeaef;
                                color: #9497b1;
                              " v-if="messageform.openStauts === 0">未开通</span></span><span class="rechargebtn"
                            @click.stop="messagepay">充值</span>
                        </div>
                      </div>
                    </template>
                    <div style="margin-top: 16px">
                      <el-form :model="eleform" label-width="120px">
                        <el-form-item label="剩余条数：">
                          <el-input v-model="messageform.smsBalance" disabled placeholder="请输入" />
                        </el-form-item>
                        <el-form-item label="发送记录：">
                          <div @click="checkmessage" style="color: rgba(35, 97, 255, 1); cursor: pointer">
                            <el-icon>
                              <Link />
                            </el-icon><span>点击查看</span>
                          </div>
                        </el-form-item>
                        <div style="
                            display: flex;
                            align-items: center;
                            justify-content: center;
                          "></div>
                      </el-form>
                    </div>
                  </el-collapse-item>
                </el-collapse>
              </div>
            </el-card>
          </div>
        </div>
      </div>
    </div>
    <!-- 产看凭证弹出框 -->
    <el-dialog v-model="dialogvoucherVisible" title="充值凭证查看" :width="isMobile ? '580' : '30%'">
      <div style="text-align: center">
        <img style="width: 100%" crossorigin="anonymous" :src="voucherimg" alt="" />
      </div>
    </el-dialog>
    <!-- 子弹发薪弹出框 -->
    <el-dialog :width="isMobile ? '580' : '30%'" v-model="dialogbulletVisible" :title="form1.companyname + '子弹发薪充值窗口'">
      <el-form ref="bullruleFormRef" :model="bullruleForm" :rules="bullrules" label-width="120px" class="demo-ruleForm"
        status-icon label-position="top">
        <el-form-item label="销售场景" prop="Salesscenario">
          <el-select v-model="bullruleForm.Salesscenario" placeholder="请选择销售场景">
            <el-option label="首签" value="0" />
            <el-option label="续签" value="1" />
          </el-select>
        </el-form-item>
        <el-form-item label="服务金额" prop="Amountofservice">
          <el-input-number v-model="bullruleForm.Amountofservice" :min="0" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="购买月份" prop="Purchasemonth">
          <el-select v-model="bullruleForm.Purchasemonth" placeholder="请选择购买月份" @change="buymounth">
            <el-option label="1个月" value="1" />
            <el-option label="2个月" value="2" />
            <el-option label="3个月" value="3" />
            <el-option label="4个月" value="4" />
            <el-option label="5个月" value="5" />
            <el-option label="6个月" value="6" />
            <el-option label="7个月" value="7" />
            <el-option label="8个月" value="8" />
            <el-option label="9个月" value="9" />
            <el-option label="10个月" value="10" />
            <el-option label="11个月" value="11" />
            <el-option label="12个月" value="12" />
          </el-select>
        </el-form-item>
        <el-form-item label="过期时间" prop="date">
          <el-date-picker v-model="bullruleForm.date" type="date" placeholder="Pick a day" disabled />
        </el-form-item>
        <el-form-item label="付款方式" prop="paytype">
          <el-select v-model="bullruleForm.paytype" placeholder="请选择付款方式">
            <el-option label="公对公" value="1" />
            <el-option label="扫码" value="2" />
            <el-option label="私对公" value="3" />
            <el-option label="赠送" value="4" />
          </el-select>
        </el-form-item>
        <el-form-item label="收款账户" prop="accounttobecredited">
          <el-select v-model="bullruleForm.accounttobecredited" placeholder="请选择收款账户">
            <el-option v-for="item in adminrechargetype" :key="item.receiptId" :label="item.bankName"
              :value="item.receiptId" />
          </el-select>
        </el-form-item>
        <el-form-item label="上传凭证">
          <div>
            <div style="width: 100px; height: auto; position: relative">
              <span v-show="payimg" style="
                  position: absolute;
                  right: -10px;
                  top: -10px;
                  background-color: rgba(86, 88, 104, 1);
                  color: white;
                  width: 20px;
                  height: 20px;
                  line-height: 20px;
                  text-align: center;
                  border-radius: 50%;
                  cursor: pointer;
                " @click="payimg = ''">x</span>
              <img crossorigin="anonymous" :src="payimg" alt="" style="width: 100%" />
            </div>
            <div>
              <input type="file" ref="fileInput" @change="handleFileChange" />
              <div></div>
            </div>
          </div>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer" style="display: flex; align-items: center; justify-content: center">
          <el-button @click="bullresetForm(bullruleFormRef)">取消</el-button>
          <el-button type="primary" @click="bullsubmitForm(bullruleFormRef)"
            style="background-color: #0256ff">确定</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 长期保弹出框 -->
    <el-dialog :width="isMobile ? '580' : '30%'" v-model="dialoglongVisible" :title="form1.companyname + '长期保充值窗口'">
      <el-form ref="longruleFormRef" :model="longruleForm" :rules="longrules" label-width="120px" class="demo-ruleForm"
        status-icon label-position="top">
        <el-form-item label="服务金额" prop="rechargeAmount">
          <el-input-number v-model="longruleForm.rechargeAmount" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="收款账户" prop="receiptId">
          <el-select v-model="longruleForm.receiptId" placeholder="请选择收款账户">
            <el-option v-for="item in adminrechargetype" :key="item.receiptId" :label="item.bankName"
              :value="item.receiptId" />
          </el-select>
        </el-form-item>
        <el-form-item label="付款方式" prop="payMode">
          <el-select v-model="longruleForm.payMode" placeholder="请选择付款方式">
            <el-option label="公对公" value="1" />
            <el-option label="扫码" value="2" />
            <el-option label="私对公" value="3" />
            <el-option label="赠送" value="4" />
          </el-select>
        </el-form-item>
        <el-form-item label="上传凭证">
          <div>
            <div style="width: 100px; height: auto; position: relative">
              <span v-show="longpayimg" style="
                  position: absolute;
                  right: -10px;
                  top: -10px;
                  background-color: rgba(86, 88, 104, 1);
                  color: white;
                  width: 20px;
                  height: 20px;
                  line-height: 20px;
                  text-align: center;
                  border-radius: 50%;
                  cursor: pointer;
                " @click="longpayimg = ''">x</span>
              <img crossorigin="anonymous" :src="longpayimg" alt="" style="width: 100%" />
            </div>
            <div>
              <input type="file" ref="longfileInput" @change="longhandleFileChange" />
              <div></div>
            </div>
          </div>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer" style="display: flex; align-items: center; justify-content: center">
          <el-button @click="longresetForm(longruleFormRef)">取消</el-button>
          <el-button @click="longsubmitForm(longruleFormRef)" type="primary"
            style="background-color: #0256ff">确定</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 日日保弹出框 -->
    <el-dialog :width="isMobile ? '580' : '30%'" v-model="dialogeveryVisible" :title="form1.companyname + '日日保充值窗口'">
      <el-form ref="everyruleFormRef" :model="everyruleForm" :rules="everyrules" label-width="120px" class="demo-ruleForm"
        status-icon label-position="top">
        <el-form-item label="服务金额" prop="rechargeAmount">
          <el-input-number v-model="everyruleForm.rechargeAmount" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="收款账户" prop="receiptId">
          <el-select v-model="everyruleForm.receiptId" placeholder="请选择收款账户">
            <el-option v-for="item in adminrechargetype" :key="item.receiptId" :label="item.bankName"
              :value="item.receiptId" />
          </el-select>
        </el-form-item>
        <el-form-item label="付款方式" prop="payMode">
          <el-select v-model="everyruleForm.payMode" placeholder="请选择付款方式">
            <el-option label="公对公" value="1" />
            <el-option label="扫码" value="2" />
            <el-option label="私对公" value="3" />
            <el-option label="赠送" value="4" />
          </el-select>
        </el-form-item>
        <el-form-item label="上传凭证">
          <div>
            <div style="width: 100px; height: auto; position: relative">
              <span v-show="everypayimg" style="
                  position: absolute;
                  right: -10px;
                  top: -10px;
                  background-color: rgba(86, 88, 104, 1);
                  color: white;
                  width: 20px;
                  height: 20px;
                  line-height: 20px;
                  text-align: center;
                  border-radius: 50%;
                  cursor: pointer;
                " @click="everypayimg = ''">x</span>
              <img crossorigin="anonymous" :src="everypayimg" alt="" style="width: 100%" />
            </div>
            <div>
              <input type="file" ref="everyfileInput" @change="everyhandleFileChange" />
              <div></div>
            </div>
          </div>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer" style="display: flex; align-items: center; justify-content: center">
          <el-button @click="everyresetForm(everyruleFormRef)">取消</el-button>
          <el-button @click="everysubmitForm(everyruleFormRef)" type="primary"
            style="background-color: #0256ff">确定</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 电子签弹出框 -->
    <el-dialog :width="isMobile ? '580' : '30%'" v-model="dialogeleVisible" :title="form1.companyname + '电子签充值窗口'">
      <el-form ref="eleruleFormRef" :model="eleruleForm" :rules="elerules" label-width="120px" class="demo-ruleForm"
        status-icon label-position="top">
        <el-form-item label="服务金额" prop="payMoney">
          <el-input-number v-model="eleruleForm.payMoney" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="份数" prop="rechargeAmount">
          <el-input-number v-model="eleruleForm.rechargeAmount" placeholder="请输入份数" />
        </el-form-item>
        <el-form-item label="付款方式" prop="payMode">
          <el-select v-model="eleruleForm.payMode" placeholder="请选择付款方式">
            <el-option label="公对公" value="1" />
            <el-option label="扫码" value="2" />
            <el-option label="私对公" value="3" />
            <el-option label="赠送" value="4" />
          </el-select>
        </el-form-item>
        <el-form-item label="收款账户" prop="receiptId">
          <el-select v-model="eleruleForm.receiptId" placeholder="请选择收款账户">
            <el-option v-for="item in adminrechargetype" :key="item.receiptId" :label="item.bankName"
              :value="item.receiptId" />
          </el-select>
        </el-form-item>
        <el-form-item label="上传凭证">
          <div>
            <div style="width: 100px; height: auto; position: relative">
              <span v-show="elepayimg" style="
                  position: absolute;
                  right: -10px;
                  top: -10px;
                  background-color: rgba(86, 88, 104, 1);
                  color: white;
                  width: 20px;
                  height: 20px;
                  line-height: 20px;
                  text-align: center;
                  border-radius: 50%;
                  cursor: pointer;
                " @click="elepayimg = ''">x</span>
              <img crossorigin="anonymous" :src="elepayimg" alt="" style="width: 100%" />
            </div>
            <div>
              <input type="file" ref="elefileInput" @change="elehandleFileChange" />
            </div>
          </div>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer" style="display: flex; align-items: center; justify-content: center">
          <el-button @click="eleresetForm(eleruleFormRef)">取消</el-button>
          <el-button @click="elesubmitForm(eleruleFormRef)" type="primary"
            style="background-color: #0256ff">确定</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 群发消息弹出框 -->
    <el-dialog :width="isMobile ? '580' : '30%'" v-model="dialogmessageVisible" :title="form1.companyname + '群发消息充值窗口'">
      <el-form ref="messageruleFormRef" :model="messageruleForm" :rules="messagerules" label-width="120px"
        class="demo-ruleForm" status-icon label-position="top">
        <el-form-item label="服务金额" prop="payMoney">
          <el-input-number v-model="messageruleForm.payMoney" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="份数" prop="rechargeAmount">
          <el-input-number v-model="messageruleForm.rechargeAmount" placeholder="请输入份数" />
        </el-form-item>
        <el-form-item label="付款方式" prop="payMode">
          <el-select v-model="messageruleForm.payMode" placeholder="请选择付款方式">
            <el-option label="公对公" value="1" />
            <el-option label="扫码" value="2" />
            <el-option label="私对公" value="3" />
            <el-option label="赠送" value="4" />
          </el-select>
        </el-form-item>
        <el-form-item label="收款账户" prop="receiptId">
          <el-select v-model="messageruleForm.receiptId" placeholder="请选择收款账户">
            <el-option v-for="item in adminrechargetype" :key="item.receiptId" :label="item.bankName"
              :value="item.receiptId" />
          </el-select>
        </el-form-item>
        <el-form-item label="上传凭证">
          <div>
            <div style="width: 100px; height: auto; position: relative">
              <span v-show="messagepayimg" style="
                  position: absolute;
                  right: -10px;
                  top: -10px;
                  background-color: rgba(86, 88, 104, 1);
                  color: white;
                  width: 20px;
                  height: 20px;
                  line-height: 20px;
                  text-align: center;
                  border-radius: 50%;
                  cursor: pointer;
                " @click="messagepayimg = ''">x</span>
              <img crossorigin="anonymous" :src="messagepayimg" alt="" style="width: 100%" />
            </div>
            <div>
              <input type="file" ref="messagefileInput" @change="messagehandleFileChange" />
            </div>
          </div>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer" style="display: flex; align-items: center; justify-content: center">
          <el-button @click="messageresetForm(messageruleFormRef)">取消</el-button>
          <el-button @click="messagesubmitForm(messageruleFormRef)" type="primary"
            style="background-color: #0256ff">确定</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 修改开通pc弹框 -->
    <el-dialog v-model="dialogchangeroleoropenpcVisible" :title="changeroleoropenpctitle" :width="isMobile ? '480' : '25%'">
      <div>
        <el-radio-group v-model="changeroleandopenpc.roleKey" size="large">
          <el-radio-button label="saas-pay-manager">发薪管理员</el-radio-button>
          <el-radio-button label="saas-pay-fa-contacter">发薪驻场</el-radio-button>
        </el-radio-group>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="changeroleoropenpcok">
            确定
          </el-button>
          <el-button @click="dialogchangeroleoropenpcVisible = false">取消</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 重置密码弹出框 -->
    <el-dialog v-model="dialogresetpasswordcVisible" title="重置密码" :width="isMobile ? '480' : '25%'">
      <el-form-item label="输入管理员密码：">
        <el-input v-model="resetpasswordform.password" type="password" placeholder="请输入管理员密码" show-password />
      </el-form-item>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="resetpasswordok"> 确定 </el-button>
          <el-button @click="resetpasswordcancel">取消</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 消息提交是否确定弹框 -->
    <el-dialog v-model="dialogmsgVisible" title="确定提交信息" :width="isMobile ? '580' : '30%'" center align-center>
      <div style="
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 18px;
        ">
        <el-icon style="color: #e6a23c">
          <WarningFilled />
        </el-icon><span>是否确定提交信息？</span>
      </div>
      <div style="
          display: flex;
          align-items: center;
          justify-content: end;
          margin-top: 20px;
        ">
        <el-button class="my_cancelbtn" @click="postmsgcancel">取消</el-button>
        <el-button type="primary" class="my_btn" @click="submitsure">确定</el-button>
      </div>
    </el-dialog>
    <!-- 查看消息弹框 -->
    <el-dialog :width="isMobile ? '1540' : '80%'" v-model="messagetable" :title="form1.companyname + '发送消息记录'">
      <template #default>
        <el-dialog v-model="messageinnerVisible" :width="isMobile ? '580' : '30%'" title="Inner Dialog" append-to-body>
          <div class="messageinnerimg">
            <img crossorigin="anonymous" :src="innerimg" alt="" />
          </div>
        </el-dialog>
        <el-table :data="messagetabledate" style="width: 100%" height="450">
          <el-table-column prop="messageTitle" label="群发标题" width="230" align="center" />
          <el-table-column prop="messageContent" label="群发消息内容" width="330" align="center">
            <template #default="scope">
              <el-tooltip class="box-item" effect="dark" :content="scope.row.messageContent" placement="bottom">
                <div style="
                    margin-right: 5px;
                    width: 300px;
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                  ">
                  {{ scope.row.messageContent }}
                </div>
              </el-tooltip>
            </template>
          </el-table-column>
          <el-table-column prop="" label="消息图片" width="180" align="center">
            <template #default="scope">
              <span v-show="scope.row.messageUrl !== null" class="checkmessageimg"
                @click="checkmessageimg(scope.row.messageUrl)">查看图片</span>
              <span v-show="scope.row.messageUrl === null">暂无</span>
            </template>
          </el-table-column>
          <el-table-column prop="sendNumber" label="发送人数" width="180" align="center">
            <template #default="scope">
              <span> {{ scope.row.sendNumber }}人 </span>
            </template>
          </el-table-column>
          <el-table-column prop="readCount" label="成功点击人数" width="180" align="center">
            <template #default="scope">
              <span> {{ scope.row.readCount }}人 </span>
            </template>
          </el-table-column>
          <el-table-column prop="smsBalance" label="发送剩余次数" width="180" align="center" />
          <el-table-column prop="sendTime" label="发送时间" width="200" align="center" />
        </el-table>
        <pagination :total="messagetotal" :currentPage="messagecurrentPage" :pageSize="messagepageSize"
          @SizeChange="messagehandleSizeChange" @CurrentChange="messagehandleCurrentChange"></pagination>
      </template>
    </el-dialog>
    <!-- 审核信息弹窗 -->
    <el-dialog v-model="dialogauditVisible" title="审核信息" :width="isMobile ? '480' : '25%'">
      <div>
        <el-form :model="form" label-width="120px">
          <el-form-item label="审核状态：">
            <el-radio-group v-model="cauditStatuscopy" @change="changeshStatus">
              <el-radio label="0">待审核</el-radio>
              <el-radio label="1">审核通过</el-radio>
              <el-radio label="2">审核驳回</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="渠道选择：">
            <el-select v-model="ditch" class="m-2" placeholder="请选择渠道信息" @change="changeauditStatus">
              <el-option v-for="item in ditchoptions" :key="item.name" :label="item.name" :value="item.id" />
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <div style="display: flex; align-items: center; justify-content: center">
        <div class="my_cancelbtn" @click="companystatuscancel" style="
            width: 60px;
            height: 30px;
            line-height: 30px;
            border-radius: 10px;
            text-align: center;
            margin: 0 10px;
          ">
          取消
        </div>
        <div class="my_btn" @click="submitditch" style="
            width: 60px;
            height: 30px;
            line-height: 30px;
            border-radius: 10px;
            text-align: center;
            margin: 0 10px;
          ">
          确定
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, computed, watch, onMounted,onActivated } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import {
  getclientsdetailapi,
  getadminrechargeapi,
  getbulletpayrollmsgapi,
  getelectronicvisaauditmsgapi,
  geteverydayinsuranceauditmsgapi,
  getlongtimeinsuranceauditmsgapi,
  getlongtimeinsuranceaudicompanytapi,
  geteverydayinsuranceaudicompanytapi,
  geteverydayinsuranceaudittypeapi,
  getlongtimeinsuranceaudittypeapi,
  getallsellerapi,
  getclientrechargeapi,
  getteamapi,
  bulletpayrechargeapi,
  everyrechargeapi,
  longrechargeapi,
  elerechargeapi,
  changeteamroleapi,
  okornologinapi,
  setorcanceladminapi,
  openpcapi,
  resetpasswordapi,
  changeclientdetailmsgapi,
  changemarketapi,
  setmarketapi,
  getmassmessageapi,
  getmassmessagemsgapi,
  messagerechargeapi,
  getditchapi
} from '../../api/api'
import pagination from '../../components/pagination.vue'
import { shake, wait } from '../../utils/utils'
import { ElMessage } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
const isMobile = ref((window as any).isMobile)

const dialogauditVisible = ref(false)
const innerimg = ref('')
const messageinnerVisible = ref(false)
const dialogvoucherVisible = ref(false)
const voucherimg = ref('')
const route = useRoute()
const messagetable = ref(false)
const foldflagone = ref<any>(null)
const foldflagtwo = ref<any>(null)
const foldflagthree = ref<any>(null)
const foldflagfour = ref<any>(null)
const foldflagfive = ref<any>(null)
const openorclose = (i: number) => {
  if (i === 1) {
    foldflagone.value = !foldflagone.value
  } else if (i === 2) {
    foldflagtwo.value = !foldflagtwo.value
  } else if (i === 3) {
    foldflagthree.value = !foldflagthree.value
  } else if (i === 4) {
    foldflagfour.value = !foldflagfour.value
  } else {
    foldflagfive.value = !foldflagfive.value
  }
}
// 渠道信息
const ditchoptions = ref<any>([])
// 获取渠道列表
const getditch = () => {
  getditchapi().then((res: any) => {
    console.log(res, 'aaaaaaaa')
    ditchoptions.value = res
  })
}
const ditch = ref('')
// 渠道选择
const changeauditStatus = (e: any) => {
  ditch.value = e
  form1.channelId = e
  console.log(cauditStatuscopy.value)
}
const changeshStatus = (e: any) => {
  console.log(e)
  cauditStatuscopy.value = e
}
// 弹窗取消关闭公司审核状态弹窗
const companystatuscancel = () => {
  dialogauditVisible.value = false
}
const submitditch = ()=>{
  changeclientdetailmsg()
}
// 开启公司审核状态弹窗
const chgangecompanystatus = () => {
  dialogauditVisible.value = true
}
const checkmessageimg = (img: any) => {
  console.log(img)
  innerimg.value = img
  messageinnerVisible.value = true
}
// 信息表格数据
const messagetabledate = ref([])
const tableData = ref([
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
])
const checkmessage = () => {
  console.log(form1.companyname)
  getmassmessage()
  messagetable.value = true
}
const getmassmessage = () => {
  getmassmessageapi({
    companyId: companyid.value,
    pageSize: teampageSize.value,
    pageNum: teamcurrentPage.value,
  }).then((res: any) => {
    console.log(res)
    messagetotal.value = res.totalCount
    messagetabledate.value = res.list
  })
}

const checkvoucher = (val: any) => {
  dialogvoucherVisible.value = true
  voucherimg.value = val
}
const changebullmarket = (val: any) => {
  console.log(val)
  bullmarkflag.value = true
}
const bullmarkflag = ref(false)
const changelongmarket = (val: any) => {
  console.log(val)
  longmarkflag.value = true
}
const longmarkflag = ref(false)
const changeeverymarket = (val: any) => {
  console.log(val)
  everymarkflag.value = true
}
const everymarkflag = ref(false)
onMounted(async () => {
  const id = route.query.id
  companyid.value = id
  getclientsdetail(companyid.value)
  getadminrecharge(companyid.value)
  getbulletpayrollmsg(companyid.value)
  getelectronicvisaauditmsg(companyid.value)
  geteverydayinsuranceauditmsg(companyid.value)
  getlongtimeinsuranceauditmsg(companyid.value)
  getmassmessagemsg(companyid.value)
  getlongtimeinsuranceaudicompanyt()
  geteverydayinsuranceaudicompanyt()
  getallsellerapi().then((res: any) => {
    console.log(res,'salename')
    allseller.value = res
  })
  getclientrecharge(companyid.value)
  getteam(companyid.value)
  getditch()
})
onActivated(async () => {
  const id = route.query.id
  companyid.value = id
  getclientsdetail(companyid.value)
  getadminrecharge(companyid.value)
  getbulletpayrollmsg(companyid.value)
  getelectronicvisaauditmsg(companyid.value)
  geteverydayinsuranceauditmsg(companyid.value)
  getlongtimeinsuranceauditmsg(companyid.value)
  getmassmessagemsg(companyid.value)
  getlongtimeinsuranceaudicompanyt()
  geteverydayinsuranceaudicompanyt()
  getallsellerapi().then((res: any) => {
    console.log(res,'salename')
    allseller.value = res
  })
  getclientrecharge(companyid.value)
  getteam(companyid.value)
  getditch()
})
const getmassmessagemsg = (id: any) => {
  getmassmessagemsgapi(id).then((res: any) => {
    console.log(res, '111111111111111111111')
    messageform.openStauts = res.openStauts
    messageform.smsBalance = res.smsBalance
  })
}
const messageform = reactive({
  openStauts: 0,
  smsBalance: 0,
})
const dialogmsgVisible = ref(false)
const setadmins = (val: any) => {
  console.log(val)
  var cisAdmin = 0
  if (val.isAdmin === 0) {
    cisAdmin = 1
  } else {
    cisAdmin = 0
  }
  setorcanceladminapi({
    companyId: val.companyId,
    isAdmin: cisAdmin,
    type: 0,
    userId: val.userId,
  }).then((res) => {
    console.log(res)
    getteam(companyid.value)
  })
}
const setorcanceladmin = (val: any) => {
  // console.log(val);
  setorcanceladminapi({
    companyId: val.companyId,
    isAdmin: 1,
    type: 1,
    userId: val.userId,
  }).then((res) => {
    // console.log(res);
    getteam(companyid.value)
  })
}
const resetpasswordcancel = () => {
  dialogresetpasswordcVisible.value = false
  resetpasswordform.password = ''
}
const resetpasswordok = () => {
  resetpasswordapi({
    id: resetpasswordform.id,
    password: resetpasswordform.password,
    userType: '02',
  }).then((res) => {
    console.log(res)
    resetpasswordcancel()
    getteam(companyid.value)
  })
}
const dialogresetpasswordcVisible = ref(false)
const resetpasswordform = reactive({
  id: 0,
  password: '',
})
const openresetpasswordzzc = (val: any) => {
  // console.log(val);
  resetpasswordform.id = val.id
  dialogresetpasswordcVisible.value = true
}
const changeroleandopenpc = reactive({
  id: 0,
  roleKey: '',
  companyId: 0,
})
const changeroleapizzc = (val: any) => {
  changeroleandopenpc.companyId = val.companyId
  changeroleandopenpc.id = val.id
  dialogchangeroleoropenpcVisible.value = true
  changeroleoropenpctitle.value = '修改角色'
}
const openpczzc = (val: any) => {
  changeroleandopenpc.companyId = val.companyId
  changeroleandopenpc.id = val.id
  dialogchangeroleoropenpcVisible.value = true
  changeroleoropenpctitle.value = '开通PC'
}
const changeroleoropenpcok = () => {
  if (changeroleoropenpctitle.value === '开通PC') {
    openpcapi({
      id: changeroleandopenpc.id,
      roleKey: changeroleandopenpc.roleKey,
      type: 'payManager',
    }).then((res) => {
      console.log(res)
      dialogchangeroleoropenpcVisible.value = false
      getteam(companyid.value)
    })
  } else {
    changeteamroleapi({
      companyId: changeroleandopenpc.companyId,
      id: changeroleandopenpc.id,
      roleKey: changeroleandopenpc.roleKey,
    }).then((res) => {
      console.log(res)
      dialogchangeroleoropenpcVisible.value = false
      getteam(companyid.value)
    })
  }
}
const dialogchangeroleoropenpcVisible = ref(false)
const changeroleoropenpctitle = ref('')

const okornologin = (val: any) => {
  console.log(val)
  let cstatus = ''
  if (val.status === '0') {
    cstatus = '1'
  } else {
    cstatus = '0'
  }
  okornologinapi({ status: cstatus, userId: val.userId }).then((res) => {
    console.log(res)
    getteam(companyid.value)
  })
}
const elefileInput = ref<any>(null)
const elehandleFileChange = () => {
  const file = elefileInput.value.files[0]
  const reader = new FileReader()
  reader.onload = (event: any) => {
    const url = event.target.result
    // console.log(url);
    elepayimg.value = url
  }
  reader.readAsDataURL(file)
}
const messagefileInput = ref<any>(null)
const messagehandleFileChange = () => {
  const file = messagefileInput.value.files[0]
  const reader = new FileReader()
  reader.onload = (event: any) => {
    const url = event.target.result
    // console.log(url);
    messagepayimg.value = url
  }
  reader.readAsDataURL(file)
}
const elepayimg = ref('')
const messagepayimg = ref('')

const everyfileInput = ref<any>(null)
const everyhandleFileChange = () => {
  const file = everyfileInput.value.files[0]
  const reader = new FileReader()
  reader.onload = (event: any) => {
    const url = event.target.result
    // console.log(url);
    everypayimg.value = url
  }
  reader.readAsDataURL(file)
}
const everypayimg = ref('')

const longfileInput = ref<any>(null)
const longhandleFileChange = () => {
  const file = longfileInput.value.files[0]
  const reader = new FileReader()
  reader.onload = (event: any) => {
    const url = event.target.result
    // console.log(url);
    longpayimg.value = url
  }
  reader.readAsDataURL(file)
}
const longpayimg = ref('')

const fileInput = ref<any>(null)
const handleFileChange = () => {
  const file = fileInput.value.files[0]
  const reader = new FileReader()
  reader.onload = (event: any) => {
    const url = event.target.result
    // console.log(url);
    payimg.value = url
  }
  reader.readAsDataURL(file)
}
const payimg = ref('')
const buymounth = (val: any) => {
  var currentExpireTime = new Date(endtime.value).getTime()
  payendtime.value = new Date(
    currentExpireTime + val * 31 * 24 * 60 * 60 * 1000
  ).toLocaleString()
  bullruleForm.date = payendtime.value
}
const payendtime = ref('')
const everysubmitForm = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      if (everypayimg.value === '') {
        ElMessage.error('请上传支付凭证')
      } else {
        everyrechargeapi({
          companyId: companyid.value,
          payMode: everyruleForm.payMode,
          receiptId: everyruleForm.receiptId,
          rechargeAmount: everyruleForm.rechargeAmount,
          voucherUrl: everypayimg.value.split(',')[1],
        }).then((res: any) => {
          console.log(res)
          if (res.code === 200) {
            ElMessage({
              message: '充值成功。',
              type: 'success',
            })
          }
          everyresetForm(everyruleFormRef.value)
          getclientsdetail(companyid.value)
          getadminrecharge(companyid.value)
          getbulletpayrollmsg(companyid.value)
          getelectronicvisaauditmsg(companyid.value)
          geteverydayinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceaudicompanyt()
          geteverydayinsuranceaudicompanyt()
          getallsellerapi().then((res: any) => {
            console.log(res)
            allseller.value = res
          })
          getclientrecharge(companyid.value)
          getteam(companyid.value)
          dialogeveryVisible.value = false
        })
      }
    } else {
      console.log('error submit!', fields)
    }
  })
}
const everyresetForm = (formEl: FormInstance | undefined) => {
  everypayimg.value = ''
  if (!formEl) return
  formEl.resetFields()
  dialogeveryVisible.value = false
}

const longsubmitForm = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      if (longpayimg.value === '') {
        ElMessage.error('请上传支付凭证')
      } else {
        longrechargeapi({
          companyId: companyid.value,
          payMode: longruleForm.payMode,
          receiptId: longruleForm.receiptId,
          rechargeAmount: longruleForm.rechargeAmount,
          voucherUrl: longpayimg.value.split(',')[1],
        }).then((res: any) => {
          console.log(res)
          if (res.code === 200) {
            ElMessage({
              message: '充值成功。',
              type: 'success',
            })
          }
          longresetForm(longruleFormRef.value)
          getclientsdetail(companyid.value)
          getadminrecharge(companyid.value)
          getbulletpayrollmsg(companyid.value)
          getelectronicvisaauditmsg(companyid.value)
          geteverydayinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceaudicompanyt()
          geteverydayinsuranceaudicompanyt()
          getallsellerapi().then((res: any) => {
            // console.log(res);
            allseller.value = res
          })
          getclientrecharge(companyid.value)
          getteam(companyid.value)
          dialoglongVisible.value = false
        })
      }
    } else {
      console.log('error submit!', fields)
    }
  })
}
const longresetForm = (formEl: FormInstance | undefined) => {
  longpayimg.value = ''
  if (!formEl) return
  formEl.resetFields()
  dialoglongVisible.value = false
}

const bullsubmitForm = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      if (payimg.value === '') {
        ElMessage.error('请上传支付凭证')
      } else {
        bulletpayrechargeapi({
          companyId: companyid.value,
          accountExpireTime: new Date(bullruleForm.date),
          payMode: bullruleForm.paytype,
          payMoney: bullruleForm.Amountofservice,
          receiptId: bullruleForm.accounttobecredited,
          salesScenario: bullruleForm.Salesscenario,
          rechargeAmount: bullruleForm.Purchasemonth,
          voucherUrl: payimg.value.split(',')[1],
          openAccountMoney: 0,
        }).then((res: any) => {
          console.log(res)
          if (res.code === 200) {
            ElMessage({
              message: '充值成功。',
              type: 'success',
            })
          }
          bullresetForm(bullruleFormRef.value)
          getclientsdetail(companyid.value)
          getadminrecharge(companyid.value)
          getbulletpayrollmsg(companyid.value)
          getelectronicvisaauditmsg(companyid.value)
          geteverydayinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceaudicompanyt()
          geteverydayinsuranceaudicompanyt()
          getallsellerapi().then((res: any) => {
            // console.log(res);
            allseller.value = res
          })
          getclientrecharge(companyid.value)
          getteam(companyid.value)
          dialogbulletVisible.value = false
        })
      }
    } else {
      console.log('error submit!', fields)
    }
  })
}
const bullresetForm = (formEl: FormInstance | undefined) => {
  dialogbulletVisible.value = false
  payimg.value = ''
  if (!formEl) return
  formEl.resetFields()
}
const bullruleFormRef = ref<FormInstance>()
const eleruleFormRef = ref<FormInstance>()
const messageruleFormRef = ref<FormInstance>()
const everyruleFormRef = ref<FormInstance>()
const longruleFormRef = ref<FormInstance>()
const bullruleForm = reactive({
  Salesscenario: '',
  Purchasemonth: '',
  Amountofservice: 0,
  date: '',
  paytype: '',
  accounttobecredited: '',
})
const bullrules = reactive<FormRules>({
  Salesscenario: [
    {
      required: true,
      message: '请选择购买月份',
      trigger: 'change',
    },
  ],
  accounttobecredited: [
    {
      required: true,
      message: '请选择收款账户',
      trigger: 'change',
    },
  ],
  paytype: [
    {
      required: true,
      message: '请选择购买月份',
      trigger: 'change',
    },
  ],
  Purchasemonth: [
    {
      required: true,
      message: '请选择销售场景',
      trigger: 'change',
    },
  ],
  Amountofservice: [
    { required: true, message: '请输入服务金额', trigger: 'blur' },
  ],
  date: [
    {
      type: 'date',
      required: true,
      message: '请选择日期',
      trigger: 'change',
    },
  ],
})
const ruleFormRef = ref<FormInstance>()

const elesubmitForm = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      if (elepayimg.value === '') {
        ElMessage.error('请上传支付凭证')
      } else {
        elerechargeapi({
          companyId: companyid.value,
          payMode: eleruleForm.payMode,
          payMoney: eleruleForm.payMoney,
          receiptId: eleruleForm.receiptId,
          rechargeAmount: eleruleForm.rechargeAmount,
          voucherUrl: elepayimg.value.split(',')[1],
        }).then((res: any) => {
          console.log(res)
          if (res.code === 200) {
            ElMessage({
              message: '充值成功。',
              type: 'success',
            })
          }
          dialogeleVisible.value = false
          eleresetForm(eleruleFormRef.value)
          getclientsdetail(companyid.value)
          getadminrecharge(companyid.value)
          getbulletpayrollmsg(companyid.value)
          getelectronicvisaauditmsg(companyid.value)
          geteverydayinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceaudicompanyt()
          geteverydayinsuranceaudicompanyt()
          getallsellerapi().then((res: any) => {
            // console.log(res);
            allseller.value = res
          })
          getclientrecharge(companyid.value)
          getteam(companyid.value)
        })
      }
    } else {
      console.log('error submit!', fields)
    }
  })
}
const eleresetForm = (formEl: FormInstance | undefined) => {
  elepayimg.value = ''
  if (!formEl) return
  formEl.resetFields()
  dialogeleVisible.value = false
}
const messagesubmitForm = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      if (messagepayimg.value === '') {
        ElMessage.error('请上传支付凭证')
      } else {
        messagerechargeapi({
          companyId: companyid.value,
          payMode: messageruleForm.payMode,
          payMoney: messageruleForm.payMoney,
          receiptId: messageruleForm.receiptId,
          rechargeAmount: messageruleForm.rechargeAmount,
          voucherUrl: messagepayimg.value.split(',')[1],
        }).then((res: any) => {
          console.log(res)
          if (res.code === 200) {
            ElMessage({
              message: '充值成功。',
              type: 'success',
            })
          }
          dialogmessageVisible.value = false
          messageresetForm(messageruleFormRef.value)
          getmassmessage()
          getclientsdetail(companyid.value)
          getadminrecharge(companyid.value)
          getbulletpayrollmsg(companyid.value)
          getelectronicvisaauditmsg(companyid.value)
          geteverydayinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceauditmsg(companyid.value)
          getlongtimeinsuranceaudicompanyt()
          geteverydayinsuranceaudicompanyt()
          getallsellerapi().then((res: any) => {
            // console.log(res);
            allseller.value = res
          })
          getclientrecharge(companyid.value)
          getteam(companyid.value)
        })
      }
    } else {
      console.log('error submit!', fields)
    }
  })
}
const messageresetForm = (formEl: FormInstance | undefined) => {
  messagepayimg.value = ''
  if (!formEl) return
  formEl.resetFields()
  dialogmessageVisible.value = false
}
const eleruleForm = reactive({
  receiptId: '',
  payMode: '',
  rechargeAmount: 0,
  payMoney: 0,
})
const messageruleForm = reactive({
  receiptId: '',
  payMode: '',
  rechargeAmount: 0,
  payMoney: 0,
})
const elerules = reactive<FormRules>({
  receiptId: [
    {
      required: true,
      message: '请选择收款账户',
      trigger: 'change',
    },
  ],
  payMode: [
    {
      required: true,
      message: '请选择收款账户',
      trigger: 'change',
    },
  ],
  payMoney: [{ required: true, message: '请输入服务金额', trigger: 'blur' }],
  rechargeAmount: [{ required: true, message: '请输入份数', trigger: 'blur' }],
})
const messagerules = reactive<FormRules>({
  receiptId: [
    {
      required: true,
      message: '请选择收款账户',
      trigger: 'change',
    },
  ],
  payMode: [
    {
      required: true,
      message: '请选择收款账户',
      trigger: 'change',
    },
  ],
  payMoney: [{ required: true, message: '请输入服务金额', trigger: 'blur' }],
  rechargeAmount: [{ required: true, message: '请输入份数', trigger: 'blur' }],
})
const everyruleForm = reactive({
  rechargeAmount: 0,
  receiptId: '',
  payMode: '',
})
const everyrules = reactive<FormRules>({
  receiptId: [
    {
      required: true,
      message: '请选择收款账户',
      trigger: 'change',
    },
  ],
  payMode: [
    {
      required: true,
      message: '请选择充值方式',
      trigger: 'change',
    },
  ],
  rechargeAmount: [
    { required: true, message: '请输入服务金额', trigger: 'blur' },
  ],
})

const longruleForm = reactive({
  rechargeAmount: 0,
  receiptId: '',
  payMode: '',
})
const longrules = reactive<FormRules>({
  receiptId: [
    {
      required: true,
      message: '请选择收款账户',
      trigger: 'change',
    },
  ],
  payMode: [
    {
      required: true,
      message: '请选择充值方式',
      trigger: 'change',
    },
  ],
  rechargeAmount: [
    { required: true, message: '请输入服务金额', trigger: 'blur' },
  ],
})

const dialogeleVisible = ref(false)
const dialogeveryVisible = ref(false)
const dialogmessageVisible = ref(false)
const dialoglongVisible = ref(false)
const dialogbulletVisible = ref(false)
const getteam = (id: any) => {
  getteamapi({
    companyId: id,
    pageNum: teamcurrentPage.value,
    pageSize: teampageSize.value,
  }).then((res: any) => {
    // console.log(res);
    teamtotal.value = res.totalCount
    teamtableData.value = res.list
  })
}
const rechargetypechange = (val: any) => {
  // console.log(val);
  radio.value = val
  getclientrecharge(companyid.value)
}
const getclientrecharge = (id: any) => {
  getclientrechargeapi({
    companyName: '',
    payMode: '',
    productType: radio.value,
    pageSize: rechargepageSize.value,
    pageNum: rechargecurrentPage.value,
  }).then((res: any) => {
    // console.log(res);
    rechargetotal.value = res.totalCount
    rechargetableData.value = res.list
  })
}
const rechargetotal = ref(0)
const rechargepageSize = ref(10)
const rechargecurrentPage = ref(1)
const teamtotal = ref(0)
const teampageSize = ref(10)
const teamcurrentPage = ref(1)
const messagetotal = ref(0)
const messagepageSize = ref(10)
const messagecurrentPage = ref(1)
const messagehandleCurrentChange = (val: any) => {
  messagecurrentPage.value = val
  getmassmessage()
}
const messagehandleSizeChange = (val: any) => {
  teampageSize.value = val
  getmassmessage()
}
const rechargehandleCurrentChange = (val: any) => {
  rechargecurrentPage.value = val
  getclientrecharge(companyid.value)
}
const rechargehandleSizeChange = (val: any) => {
  rechargepageSize.value = val
  getclientrecharge(companyid.value)
}
const teamhandleCurrentChange = (val: any) => {
  teamcurrentPage.value = val
  getteam(companyid.value)
}
const teamhandleSizeChange = (val: any) => {
  teampageSize.value = val
  getteam(companyid.value)
}
const allseller = ref<any>([])
const changelongtimecompany = async (val: any) => {
  console.log(val)
  longbxtype.value = []
  val.forEach((ele: any, index: any) => {
    getlongtimeinsuranceaudittypeapi(ele).then((res: any) => {
      // console.log(res);
      longbxtype.value.push(...res)
    })
  })
  await wait(200)
  // console.log(longbxtype.value);
  var arr = longbxtype.value.map((item: any, i: any) => {
    return item.dictValue
  })
  var newarr: any = []
  longform.bxtype.forEach((ele: any, index: any) => {
    var flag = arr.findIndex((val: any, i: any) => {
      return val === ele
    })
    if (flag !== -1) {
      // console.log(ele);
      newarr.push(ele)
    }
  })
  longform.bxtype = newarr
}
const longbxtype = ref<any>([])
const changexs = (val: any) => {
  bulletform.paySaleid = val
}
const changeeledate = (val: any) => {
  eleform.eleProductOpenTime = val.toLocaleDateString()
}
const changeeverybxcompany = (val: any) => {
  everyform.bxtype = []
  everyform.bxcompany = val
  geteverydayinsuranceaudittype(everyform.bxcompany)
  everyform.bxtype = []
}
const everybxtype = ref<any>([])
const geteverydayinsuranceaudittype = (val: string) => {
  geteverydayinsuranceaudittypeapi(val).then((res) => {
    // console.log(res);
    everybxtype.value = res
  })
}
const getlongtimeinsuranceaudittype = (val: string) => {
  getlongtimeinsuranceaudittypeapi(val).then((res) => {
    // console.log(res);
  })
}
const cpaySaleName = ref('')
// 获取长期保保司
const getlongtimeinsuranceaudicompanyt = () => {
  getlongtimeinsuranceaudicompanytapi().then((res: any) => {
    // console.log(res);
    longbxcompany.value = res
  })
}
// 获取日日保保司
const geteverydayinsuranceaudicompanyt = () => {
  geteverydayinsuranceaudicompanytapi().then((res) => {
    console.log(res, 'testtest')
    dailybxcompany.value = res
  })
}
const dailybxcompany = ref<any>([])
const getbulletpayrollmsg = (id: any) => {
  getbulletpayrollmsgapi(id).then((res: any) => {
    // console.log(res);
    bullsetorchange.value = res.saleId === null ? true : false
    bulldealId.value = res.dealId
    bullsale0ldId.value = res.saleId
    bullserviceState.value = res.serviceState
    bulletform.receiptId = res.receiptId
    bulletform.paySaleid = res.saleId
    bulletform.validTime = res.validTime
    bulletform.patMoneyCount = res.patMoneyCount
    bulletform.subMchid = res.subMchid
    bulletform.dailyQuota = res.dailyQuota
    bulletform.personSingleQuota = res.personSingleQuota
    bulletform.payAccountBalance = res.payAccountBalance
    bulletform.merchantBankCard = res.merchantBankCard
    bulletform.isOpenPaySalary = res.isOpenPaySalary
    cpaySaleName.value = res.paySaleName
  })
}
const bullsetorchange = ref(false)
const bulldealId = ref(0)
const bullsale0ldId = ref(0)
const bullserviceState = ref(0)
const getelectronicvisaauditmsg = (id: any) => {
  getelectronicvisaauditmsgapi(id).then((res: any) => {
    // console.log(res);
    eleform.isOpenEleSign = res.isOpenEleSign
    eleform.eleAmount = res.eleAmount
    eleform.eleSignConsumeAmount = res.eleSignConsumeAmount
    eleform.signingFailedRecordAmount = res.signingFailedRecordAmount
    eleform.eleProductOpenTime = res.eleProductOpenTime
  })
}
const eleform = reactive<any>({
  isOpenEleSign: '',
  eleAmount: '',
  eleSignConsumeAmount: '',
  signingFailedRecordAmount: '',
  eleProductOpenTime: '',
})
const geteverydayinsuranceauditmsg = (id: any) => {
  geteverydayinsuranceauditmsgapi(id).then((res: any) => {
    console.log(res)
    everysetorchange.value = res.saleId === null ? true : false
    everydealId.value = res.dealId
    everysale0ldId.value = res.saleId
    everyserviceState.value = res.serviceState
    everyform.saleId = res.saleId
    everyform.isOpenWesure = res.isOpenWesure
    everyform.productOpenTime = res.productOpenTime
    everyform.insureIncreaseRate = res.insureIncreaseRate
    everyform.insureClaimRate = res.insureClaimRate
    everyform.plach = res.saleName
    everyform.ye = res.wesureBalance
    if (res.insureCompanyType[0] === null) {
      everyform.bxcompany = ''
      everyform.bxtype = []
    } else {
      everyform.bxcompany = res.insureCompanyType
      geteverydayinsuranceaudittype(res.insureCompanyType[0])
      everyform.bxtype = res.insureType
    }
  })
}
const everysetorchange = ref(false)
const everydealId = ref(0)
const everysale0ldId = ref(0)
const everyserviceState = ref(0)
const everyform = reactive<any>({
  isOpenWesure: '',
  productOpenTime: '',
  insureIncreaseRate: '',
  insureClaimRate: '',
  plach: '',
  ye: '',
  bxcompany: [],
  bxtype: [],
})
const getlongtimeinsuranceauditmsg = (id: any) => {
  getlongtimeinsuranceauditmsgapi(id).then((res: any) => {
    // console.log(res);
    longsetorchange.value = res.saleId === null ? true : false
    longdealId.value = res.dealId
    longsale0ldId.value = res.saleId
    longserviceState.value = res.serviceState
    longform.longxs = res.saleId
    longform.isOpenPeriod = res.isOpenPeriod
    longform.productOpenTime = res.productOpenTime
    longform.periodInsureCount = res.periodInsureCount
    longform.insureClaimRate = res.insureClaimRate
    longform.wesureBalance = res.wesureBalance
    clongxs.value = res.saleName
    if (res.periodCompanyTypeList.length === 0) {
      longform.bxcompany = []
      longbxtype.value = []
      longform.bxtype = []
    } else {
      longform.bxcompany = res.periodCompanyTypeList
      // longform.bxtype = res.periodPlanTypeList;
      longform.bxtype = res.periodPlanTypeList.map((ele: any, index: any) => {
        return ele.split('======')[1]
      })
      longbxtype.value = []
      longform.bxcompany.forEach((ele: any, index: any) => {
        getlongtimeinsuranceaudittypeapi(ele).then((res: any) => {
          // console.log(res);
          longbxtype.value.push(...res)
        })
      })
    }
  })
}
const longsetorchange = ref(false)
const longdealId = ref(0)
const longsale0ldId = ref(0)
const longserviceState = ref(0)
const longform = reactive<any>({
  isOpenPeriod: null,
  productOpenTime: '',
  periodInsureCount: '',
  insureClaimRate: '',
  longxs: '',
  wesureBalance: '',
  bxcompany: [],
  bxtype: [],
})
const clongxs = ref('')
const elepay = () => {
  dialogeleVisible.value = true
}
const longpay = () => {
  dialoglongVisible.value = true
}
const everypay = () => {
  dialogeveryVisible.value = true
}
const messagepay = () => {
  dialogmessageVisible.value = true
}
// 子弹充值
const bulletpayrechargeapipay = () => {
  dialogbulletVisible.value = true
}
const adminrechargetype = ref<any>([])
const smsBalance = ref(0)
const getclientsdetail = (id: number) => {
  getclientsdetailapi(id).then((res: any) => {
    console.log(res)
    smsBalance.value = res.smsBalance
    form1.receiptId = res.receiptId
    form1.address = res.area
    form1.companyname = res.companyName
    form1.companyAbbreviation = res.companyAbbreviation
    form1.legalpersonname = res.legalPerson
    form1.coding = res.creditCode
    form1.bankName = res.bankName
    form1.channelId = res.channelId
    ditch.value = res.channelId
    form1.openingbank = res.merchantBankCard
    starttime.value = res.openAnAccountTime
    endtime.value = res.expirationDate
    cauditStatus.value = res.auditStatus
    cauditStatuscopy.value = res.auditStatus.toString()
    if (res.auditStatus === 0) {
      auditStatus.value = '待审核'
    } else if (res.auditStatus === 1) {
      auditStatus.value = '审核通过'
    } else {
      auditStatus.value = '审核驳回'
    }
  })
}
const statusoptions = [
  {
    value: 0,
    label: '待审核',
  },
  {
    value: 1,
    label: '审核通过',
  },
  {
    value: 2,
    label: '审核驳回',
  },
]
const starttime = ref('')
const endtime = ref('')
const getadminrecharge = (id: any) => {
  getadminrechargeapi(id).then((res: any) => {
    console.log(res, '11111111111')
    adminrechargetype.value = res
    let id = ''
    res.forEach((ele: any, index: any) => {
      if (ele.isDistribution === 1) {
        id = ele.receiptId
      }
    })
    messageruleForm.receiptId = id
    eleruleForm.receiptId = id
    everyruleForm.receiptId = id
    longruleForm.receiptId = id
    bullruleForm.accounttobecredited = id
  })
}
const auditStatus = ref('')
const cauditStatus = ref('')
const cauditStatuscopy = ref('')
const companyid = ref()
const value = ref('')
const radio = ref('')
const handleClick = () => {
  console.log('click')
}
const teamtableData = ref<any>([])
const rechargetableData = ref([])
// 表单绑定数据
const form1 = reactive({
  companyAbbreviation: '',
  companyname: '',
  receiptaccount: '',
  coding: '',
  legalpersonname: '',
  openingbank: '',
  address: '',
  receiptId: '',
  bankName: '',
  channelId: null
})
const form = reactive({
  name: '',
  date: '',
  region: '',
})
const bulletform = reactive<any>({
  validTime: '',
  patMoneyCount: '',
  payAccountBalance: '',
  subMchid: '',
  dailyQuota: '',
  personSingleQuota: '',
  receiptId: '',
  merchantBankCard: '',
  isOpenPaySalary: '',
  paySaleid: '',
})
const submitflag = ref('')
// 基本信息取消
const basemsgcancel = () => {
  getclientsdetail(companyid.value)
}
// 基本信息提交
const basemsgonSubmit = (val: string) => {
  submitflag.value = val
  dialogmsgVisible.value = true
}
// 子弹发薪信息提交
const bullmsgonSubmit = (val: string, statrus: any) => {
  submitflag.value = val
  changestatus.value = statrus
  dialogmsgVisible.value = true
}
const changestatus = ref(0)
// 电子签信息提交
const elemsgonSubmit = (val: string) => {
  submitflag.value = val
  dialogmsgVisible.value = true
}
// 日日保薪信息提交
const everymsgonSubmit = (val: string, statrus: any) => {
  submitflag.value = val
  changestatus.value = statrus
  dialogmsgVisible.value = true
}
// 长期保薪信息提交
const longmsgonSubmit = (val: string, statrus: any) => {
  submitflag.value = val
  changestatus.value = statrus
  dialogmsgVisible.value = true
}

// 修改客户详情信息
const changeclientdetailmsg = () => {
  changeclientdetailmsgapi({
    id: companyid.value,
    auditStatus: cauditStatuscopy.value,
    companyAbbreviation: form1.companyname,
    receiptId: form1.receiptId,
    creditCode: form1.coding,
    legalPerson: form1.legalpersonname,
    merchantBankCard: form1.openingbank,
    area: form1.address,
    channelId: form1.channelId
  }).then((res: any) => {
    console.log(res)
    dialogauditVisible.value = false
    getclientsdetail(companyid.value)
    getbulletpayrollmsg(companyid.value)
    if (res.code === 200) {
      ElMessage({
        message: '修改成功。',
        type: 'success',
      })
    }
  })
}

const submitsure = () => {
  const y = new Date().getFullYear()
  const m =
    new Date().getMonth() + 1 >= 10
      ? new Date().getMonth() + 1
      : 0 + new Date().getMonth() + 1
  if (submitflag.value === 'basemsg') {
    // console.log("basemsg");
    changeclientdetailmsg()
    dialogmsgVisible.value = false
  } else if (submitflag.value === 'bullmsg') {
    if (bullmarkflag.value) {
      if (bullsetorchange.value) {
        setmarketapi({
          companyId: companyid.value,
          id: bulldealId.value,
          productType: 0,
          saleId: bulletform.paySaleid,
          serviceStartTime: `${y}-${m}-01`,
          serviceState: bullserviceState.value,
        }).then((res: any) => {
          console.log(res)
          ElMessage({
            message: '修改成功。',
            type: 'success',
          })
          getbulletpayrollmsg(companyid.value)
        })
      } else {
        changemarketapi({
          companyId: companyid.value,
          id: bulldealId.value,
          productType: 0,
          saleId: bulletform.paySaleid,
          serviceStartTime: `${y}-${m}-01`,
          saleOldId: bullsale0ldId.value,
          serviceState: bullserviceState.value,
        }).then((res: any) => {
          console.log(res)
          ElMessage({
            message: '修改成功。',
            type: 'success',
          })
          getbulletpayrollmsg(companyid.value)
        })
      }
    }
    changeclientdetailmsgapi({
      id: companyid.value,
      auditStatus: cauditStatus.value,
      companyAbbreviation: form1.companyname,
      receiptId: bulletform.receiptId,
      creditCode: form1.coding,
      legalPerson: form1.legalpersonname,
      merchantBankCard: bulletform.merchantBankCard,
      area: form1.address,
      isOpenPaySalary: changestatus.value,
      subMchid: bulletform.subMchid,
      dailyQuota: bulletform.dailyQuota,
      personSingleQuota: bulletform.personSingleQuota,
    }).then((res) => {
      console.log(res)
      getclientsdetail(companyid.value)
      getbulletpayrollmsg(companyid.value)
      dialogmsgVisible.value = false
    })
    // console.log("bullmsg");
  } else if (submitflag.value === 'longmsg') {
    // console.log("longmsg");
    if (longmarkflag.value) {
      if (longsetorchange.value) {
        setmarketapi({
          companyId: companyid.value,
          id: longdealId.value,
          productType: 3,
          saleId: longform.longxs,
          serviceStartTime: `${y}-${m}-01`,
          serviceState: longserviceState.value,
        }).then((res) => {
          console.log(res)
          getlongtimeinsuranceauditmsg(companyid.value)
        })
      } else {
        changemarketapi({
          companyId: companyid.value,
          id: longdealId.value,
          productType: 3,
          saleId: longform.longxs,
          serviceStartTime: `${y}-${m}-01`,
          saleOldId: longsale0ldId.value,
          serviceState: longserviceState.value,
        }).then((res) => {
          console.log(res)
          getlongtimeinsuranceauditmsg(companyid.value)
        })
      }
    }
    var a = longform.bxtype
    a = a.map((ele: any, index: number) => {
      if (ele.includes('XDC')) {
        return (ele = 'period_002_xdc======' + ele)
      }
      if (ele.includes('TPC')) {
        return (ele = 'period_004_tpc======' + ele)
      }
      if (ele.includes('ZGRS')) {
        return (ele = 'period_001_zgrs======' + ele)
      }
      if (ele.includes('JSYG')) {
        return (ele = 'period_003_jsyg======' + ele)
      }
      if (ele.includes('YG')) {
        return (ele = 'period_003_yg======' + ele)
      }
    })
    changeclientdetailmsgapi({
      id: companyid.value,
      auditStatus: cauditStatus.value,
      companyAbbreviation: form1.companyname,
      receiptId: form1.receiptId,
      creditCode: form1.coding,
      legalPerson: form1.legalpersonname,
      merchantBankCard: form1.openingbank,
      area: form1.address,
      isOpenPeriod: changestatus.value,
      periodCompanyTypeList: longform.bxcompany,
      periodPlanTypeList: a,
    }).then((res) => {
      console.log(res)
      ElMessage({
        message: '修改成功。',
        type: 'success',
      })
      getlongtimeinsuranceauditmsg(companyid.value)
      dialogmsgVisible.value = false
    })
  } else if (submitflag.value === 'everymsg') {
    console.log('everymsg')
    if (everymarkflag.value) {
      if (everysetorchange.value) {
        setmarketapi({
          companyId: companyid.value,
          id: everydealId.value,
          productType: 2,
          saleId: everyform.saleId,
          serviceStartTime: `${y}-${m}-01`,
          serviceState: everyserviceState.value,
        }).then((res) => {
          console.log(res)
          ElMessage({
            message: '修改成功。',
            type: 'success',
          })
          geteverydayinsuranceauditmsg(companyid.value)
        })
      } else {
        changemarketapi({
          companyId: companyid.value,
          id: everydealId.value,
          productType: 2,
          saleId: everyform.saleId,
          serviceStartTime: `${y}-${m}-01`,
          saleOldId: everysale0ldId.value,
          serviceState: everyserviceState.value,
        }).then((res) => {
          console.log(res)
          ElMessage({
            message: '修改成功。',
            type: 'success',
          })
          geteverydayinsuranceauditmsg(companyid.value)
        })
      }
    }
    changeclientdetailmsgapi({
      id: companyid.value,
      auditStatus: cauditStatus.value,
      companyAbbreviation: form1.companyname,
      receiptId: form1.receiptId,
      creditCode: form1.coding,
      legalPerson: form1.legalpersonname,
      merchantBankCard: form1.openingbank,
      area: form1.address,
      isOpenWesure: changestatus.value,
      insureCompanyType: everyform.bxcompany[0],
      insureTypeList: everyform.bxtype,
    }).then((res) => {
      console.log(res)
      geteverydayinsuranceauditmsg(companyid.value)
      dialogmsgVisible.value = false
    })
  }
}
const postmsgcancel = () => {
  if (submitflag.value === 'basemsg') {
    console.log('basemsg')
    getclientsdetail(companyid.value)
    dialogmsgVisible.value = false
  } else if (submitflag.value === 'bullmsg') {
    console.log('bullmsg')
    getbulletpayrollmsg(companyid.value)
    dialogmsgVisible.value = false
  } else if (submitflag.value === 'longmsg') {
    console.log('longmsg')
    dialogmsgVisible.value = false
    getlongtimeinsuranceauditmsg(companyid.value)
  } else if (submitflag.value === 'everymsg') {
    console.log('everymsg')
    dialogmsgVisible.value = false
    geteverydayinsuranceauditmsg(companyid.value)
  }
}

const onSubmit = () => {
  console.log('submit!')
}
const options = [
  {
    value: 'Option1',
    label: 'Option1',
  },
  {
    value: 'Option2',
    label: 'Option2',
  },
  {
    value: 'Option3',
    label: 'Option3',
  },
  {
    value: 'Option4',
    label: 'Option4',
  },
  {
    value: 'Option5',
    label: 'Option5',
  },
]
const longbxcompany = ref<any>([])
const back = () => {
  window.history.back()
}
</script>

<style lang="scss" scoped>
.pagination {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: end;
}

.company {
  .companystatus {
    display: flex;
    align-items: center;
    justify-content: start;

    span {
      font-weight: 700;
      margin-right: 20px;
    }
  }

  .companyse_time {
    margin-top: 20px;
    display: flex;

    .l {
      padding-right: 20px;
      border-right: 2px solid rgba(216, 216, 216, 1);
      display: flex;
      align-items: center;

      img {
        margin-right: 10px;
      }
    }

    .r {
      border-right: 2px solid rgba(216, 216, 216, 1);
      padding-left: 20px;
      padding-right: 20px;
      display: flex;
      align-items: center;

      img {
        margin-right: 10px;
      }
    }

    .note {
      padding-left: 20px;
      padding-right: 20px;
      display: flex;
      align-items: center;

      img {
        margin-right: 10px;
      }
    }
  }
}

.content {
  padding: 16px;
}

.companymsg {
  margin-top: 16px;
  display: flex;

  .l {
    width: 70%;
    margin-right: 20px;

    .basemsg {
      .title {
        height: 48px;
        line-height: 48px;
        border-bottom: 1px solid rgba(244, 244, 247, 1);
        font-size: 16px;
        color: rgba(61, 61, 61, 1);
        font-weight: 700;
      }
    }

    .team {
      margin-top: 16px;

      .title {
        height: 48px;
        line-height: 48px;
        border-bottom: 1px solid rgba(244, 244, 247, 1);
        font-size: 16px;
        color: rgba(61, 61, 61, 1);
        font-weight: 700;
      }
    }

    .recharge {
      margin-top: 16px;

      .title {
        height: 48px;
        line-height: 48px;
        border-bottom: 1px solid rgba(244, 244, 247, 1);
        font-size: 16px;
        color: rgba(61, 61, 61, 1);
        font-weight: 700;
      }
    }
  }

  .r {
    width: 29%;

    .goodsmsg {

      //   margin-top: 16px;
      .title {
        height: 48px;
        line-height: 48px;
        border-bottom: 1px solid rgba(244, 244, 247, 1);
        font-size: 16px;
        color: rgba(61, 61, 61, 1);
        font-weight: 700;
      }

      .collapse_title {
        // border-radius: 10px;
        width: 100%;
        box-sizing: border-box;
        padding: 5px;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }
    }
  }
}

.rechargebtn {
  color: #0256ff;
  margin-right: 16px;
}

.fold {
  margin-left: 16px;
  margin-top: 3px;
  margin-right: 10px;
  // transform: rotate(0deg);
}

.foldflagup {
  transform: rotate(0deg);
  animation: foldup 0.4s linear;
}

.foldflagdown {
  transform: rotate(90deg);
  animation: folddown 0.4s linear;
}

@keyframes folddown {
  0% {
    transform: rotate(0);
  }

  100% {
    transform: rotate(90deg);
  }
}

@keyframes foldup {
  0% {
    transform: rotate(90deg);
  }

  100% {
    transform: rotate(0);
  }
}

.left_btn {
  width: 32px;
  height: 22px;

  img {
    width: 100%;
    height: 100%;
  }
}

.checkmessageimg {
  cursor: pointer;
  color: #3e5ff5;
}

.messageinnerimg {
  width: 100%;
  min-height: 150px;

  img {
    width: auto;
    max-width: 100%;
    height: 100%;
  }
}

.companystatuslist {
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  width: 100px;
  height: 24px;
  border: 1px solid #ccc;
  cursor: pointer;
  box-sizing: border-box;
  color: #606266;
}
</style>
